/*
	@desc  独立按键控制LED
	@date 20140518
	@author LiWang112358
*/
#include <reg52.h>

int delay(int x)
{
	int i;
	for (i = 0; i < x; ++ i);
	return 0;
}

int getP0(unsigned int i)
{
	return P0 & (1<<i);
}

int changeP1(unsigned int i)
{
	P1 = P1 ^ (1<<i);
	return 0;
}

int main()
{
	unsigned int i;
	while(1){
		for (i = 0; i < 8; ++ i){
			if (0 == getP0(i)){
				delay(5000);
				if (0 == getP0(i)){
					while (0==getP0(i));
					changeP1(i);
				}
			}
		}
	}
	return 0;
}